package com.ylr.blog.framework.controller.api;

import com.ylr.base.common.tool.Result;
import com.ylr.blog.framework.feign.YbBlogSpaceBaseClient;
import com.ylr.blog.framework.service.BlogSpaceService;
import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-05-19 21:38:21
 * className: BlogSpaceApiController
 * version: 1.0
 * description:
 */
@RestController
@RequestMapping("/api/blog-space")
@AllArgsConstructor
public class BlogSpaceApiController implements YbBlogSpaceBaseClient {

    private static final Logger log = LoggerFactory.getLogger(BlogSpaceApiController.class);

    private final BlogSpaceService blogSpaceService;

    /**
     * 添加用户博客空间接口
     * @param userId 用户主键
     * @param name   空间名称
     */
    @PostMapping("/add")
    public Result<Object> addBlogSpace(@RequestParam("userId") Long userId, @RequestParam("name") String name) {
        log.info("api => 开始添加用户博客空间操作。userId={} name={}", userId, name);

        blogSpaceService.addBlogSpace(userId, name);

        log.info("api => 添加用户博客空间操作结束");
        return Result.success();
    }
}
